//
//  SetViewController.m
//  CC_Weather
//
//  Created by rimi on 16/9/23.
//  Copyright © 2016年 cc. All rights reserved.
//

#import "SetViewController.h"

@interface SetViewController ()<UITableViewDataSource,UITableViewDelegate>

- (void)initUserInterface;/**<初始化界面 */
- (void)initDataSource;/**<初始化数据 */
@property(nonatomic, strong)UITableView *tableView;
@property(nonatomic, strong)NSMutableArray *dataSource;

@end

@implementation SetViewController


#pragma mark - life circle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    [self initDataSource];
    [self initUserInterface];
}


#pragma mark - init

- (void)initDataSource{
    
    _dataSource = [NSMutableArray array];
    _dataSource = @[@"检查更新",@"关于"].mutableCopy;
    
}

-(void)initUserInterface{
    self.view.backgroundColor = [UIColor colorWithRed:0.432 green:0.5245 blue:0.705 alpha:1.0];

     //navigationBar
    self.navigationController.navigationBar.translucent = true;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    //logo
    UIImageView *logoImageView = [[UIImageView alloc]init];
    logoImageView.center = CGPointMake(SCREEN_WIDTH * 0.5, SCREEN_HEIGHT * 0.3);
    logoImageView.bounds = CGRectMake(0, 0, 150, 150);
    logoImageView.image = [UIImage imageNamed:@"logo"];
    [self.view addSubview:logoImageView];
    
    //tableView
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT * 0.5, SCREEN_WIDTH, SCREEN_HEIGHT * 0.5) style:UITableViewStylePlain];
    _tableView.rowHeight = 50;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.bounces = NO;
    _tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.view addSubview:_tableView];
}


#pragma mark - protocol
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    
    cell.textLabel.text = _dataSource[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:
            [NetRequst alert:@"已是最新版！"];
            break;
            
        case 1:
            
            break;
            
        default:
            break;
    }
}


@end
